package com.controller;

import com.exception.ValidateException;
import com.pojo.Extend;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@Api(tags = {"测试继承"})
public class ExtendCtrl {

    @PostMapping(value = "/extend")
    @ApiOperation(value = "测试继承接口")
    public ResponseEntity<Extend> extend(@RequestBody @Valid Extend extend, BindingResult result){
        if (result.hasErrors()){
            throw new ValidateException(result.getFieldErrors());
        }
        return ResponseEntity.ok(extend);
    }
}
